/**
 * Company : SIANGKLOM.
 * Created By : Chatree Siangklom
 * Created On : Oct 9, 2013  5:19:29 PM 
 * e-Mail : dr_chatree@hotmail.com
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : com.tis.database.services.staging.impl
 * File Name : FiCreditNoteOutbServicesImpl.java
 * TODO
 */
package com.tis.database.services.staging.impl;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.hibernate.HibernateException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import sap.business.enumeration.STAGING_STATUS;

import com.tis.database.dao.staging.FiCreditNoteOutbDao;
import com.tis.database.entitys.SapMessage;
import com.tis.database.entitys.staging.FiCreditNoteOutb;
import com.tis.database.entitys.staging.StampObject;
import com.tis.database.services.staging.IFiCreditNoteOutbServices;

/**
 * @author Chatree Siangklom of Administrator
 * Date =Oct 9, 2013 : 5:19:29 PM 
 * CreateBy=Chatree Siangklom
 * 
 * FiCreditNoteOutbServicesImpl
 * TODO
 */
@Service
@Transactional(readOnly=true)
public class FiCreditNoteOutbServicesImpl implements IFiCreditNoteOutbServices {
	
	private static final Logger logging = LoggerFactory .getLogger(FiCreditNoteOutbServicesImpl.class);

	@Autowired FiCreditNoteOutbDao fiCreditNoteOutbDao;

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#Search(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int)
	 * Date =Oct 9, 2013 : 5:19:29 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	
	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#saveOrUpdate(com.tis.database.entitys.staging.FiCreditNoteOutb)
	 * Date =Oct 9, 2013 : 5:22:07 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void saveOrUpdate(FiCreditNoteOutb e) throws HibernateException, Exception {
		fiCreditNoteOutbDao.saveOrUpdate(e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#saveOrUpdate(java.util.List)
	 * Date =Oct 9, 2013 : 5:22:07 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void saveOrUpdate(List<FiCreditNoteOutb> e) throws HibernateException, Exception {

		fiCreditNoteOutbDao.saveOrUpdate(e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#findById(java.lang.String)
	 * Date =Oct 9, 2013 : 5:22:07 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public FiCreditNoteOutb findById(String id) throws HibernateException, Exception {

		return fiCreditNoteOutbDao.findById(id);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#NextSequence(java.lang.String)
	 * Date =Oct 9, 2013 : 5:22:07 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public BigDecimal NextSequence(String name) throws HibernateException, Exception {

		return fiCreditNoteOutbDao.NextSequence(name);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#Search(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int)
	 * Date =Oct 11, 2013 : 2:07:20 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public List<FiCreditNoteOutb> Search(String id, 
			String sapstagingId,
			String company, 
			String project, 
			String documentNo, 
			String refDocNo,
			String accountCode, 
			String accountCode2, 
			String unitNo,
			String status, 
			String instanceNo, 
			String syncIssync,
			String interfaceOnStart, 
			String interfaceOnEnd, 
			int maxResult) throws HibernateException, Exception {
		// TODO Auto-generated method stub
		return fiCreditNoteOutbDao.Search(id, sapstagingId, company, project, documentNo, refDocNo, accountCode, accountCode2, unitNo, status, instanceNo, syncIssync, interfaceOnStart, interfaceOnEnd, maxResult);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#UpdateBackSapMessage(java.util.List)
	 * Date =Oct 15, 2013 : 2:56:17 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public List<FiCreditNoteOutb> UpdateBackSapMessage(List<SapMessage> sapMessages) throws HibernateException, Exception {
		// TODO Auto-generated method stub
		return fiCreditNoteOutbDao.UpdateBackSapMessage(sapMessages);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#NextInstanceNo()
	 * Date =Oct 16, 2013 : 10:21:24 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public BigDecimal NextInstanceNo() throws HibernateException, Exception {
		return fiCreditNoteOutbDao.NextInstanceNo();
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#NextSequence()
	 * Date =Oct 16, 2013 : 10:24:17 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public BigDecimal NextSequence() throws HibernateException, Exception {
		// TODO Auto-generated method stub
		return fiCreditNoteOutbDao.NextSequence("FI_CREDIT_NOTE_OUTB");
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#getCurrentDatabaseDate()
	 * Date =Oct 17, 2013 : 5:48:08 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public Date getCurrentDatabaseDate() throws HibernateException, Exception {
		// TODO Auto-generated method stub
		return fiCreditNoteOutbDao.getCurrentDatabaseDate();
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#StampUsedTime(com.tis.database.entitys.staging.StampObject, com.tis.database.entitys.staging.FiCreditNoteOutb)
	 * Date =Oct 18, 2013 : 11:35:58 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTime(StampObject stampObject, FiCreditNoteOutb e) throws Exception {
		fiCreditNoteOutbDao.StampUsedTime(stampObject, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#StampUsedTimePROC(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.FiCreditNoteOutb)
	 * Date =Oct 18, 2013 : 1:42:25 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTimePROC(String instanceNo, Date procStartTime, Date procEndTime, FiCreditNoteOutb e) throws Exception {

		fiCreditNoteOutbDao.StampUsedTimePROC(instanceNo, procStartTime, procEndTime, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#StampUsedTimeSend(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.FiCreditNoteOutb)
	 * Date =Oct 18, 2013 : 1:42:25 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTimeSend(String instanceNo, Date sendUseStart, Date sendUseEnd, FiCreditNoteOutb e) throws Exception {

		fiCreditNoteOutbDao.StampUsedTimeSend(instanceNo, sendUseStart, sendUseEnd, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#StampUsedTimePms(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.FiCreditNoteOutb)
	 * Date =Oct 18, 2013 : 1:42:25 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTimePms(String instanceNo, Date pmsUseStart, Date pmsUseEnd, FiCreditNoteOutb e) throws Exception {

		fiCreditNoteOutbDao.StampUsedTimePms(instanceNo, pmsUseStart, pmsUseEnd, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#findByInstanceNo(java.lang.String, com.tis.database.entitys.staging.FiCreditNoteOutb)
	 * Date =Oct 18, 2013 : 2:34:10 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public List<FiCreditNoteOutb> findByInstanceNo(String instanceNo, FiCreditNoteOutb e) throws HibernateException, Exception {
		
		return fiCreditNoteOutbDao.findByInstanceNo(instanceNo, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiCreditNoteOutbServices#SaveErrorToStaging(java.lang.String, sap.business.enumeration.STAGING_STATUS, java.lang.String)
	 * Date =Oct 25, 2013 : 10:56:01 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void SaveErrorToStaging(String instanceNo, STAGING_STATUS Staging_STATUS, String error) {
		
		fiCreditNoteOutbDao.SaveErrorToStaging(instanceNo, Staging_STATUS, error);
	}
	

}
